import React from 'react';
import {inject, observer} from 'mobx-react';
import {Button, message} from 'antd';
import * as Util from '../../../util/Util';
import FeedBack from '../../../public/feedback/FeedBack';
import {WeaLocaleProvider, WeaRichText, WeaSearchGroup} from 'ecCom';

const toJS = mobx.toJS;
const getLabel = WeaLocaleProvider.getLabel;

/**
 * 绩效评分反馈
 */

@inject("accessViewStore")
@observer
export default class AccessViewFb extends React.Component {

    constructor(props) {
        super(props);
        this.state = {}
    }

    componentWillMount() {//一些初始化请求
        const {accessViewStore} = this.props;
        accessViewStore.getAccessFbInfo({});
    }

    submitFb() {
        const {accessViewStore} = this.props;
        if (accessViewStore.fbcontent != "") {
            accessViewStore.getAccessFbInfo({content: accessViewStore.fbcontent, operation: "save"});
        } else {
            message.warning(getLabel('508896', '反馈内容不能为空'));
        }
    }

    setfeedbackContent(v) {
        const {accessViewStore} = this.props;
        accessViewStore.fbcontent = v;
    }

    render() {
        const {accessViewStore} = this.props;
        const {fbInfoList, fbcontent} = accessViewStore;
        return (
            <div className="wea-workrelate-perfor-accessviewfb" style={{height: '100%'}}>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@1fxwgj`} title={getLabel('33956', '意见反馈')} showGroup={true}>
                    <WeaRichText ecId={`${this && this.props && this.props.ecId || ''}_WeaRichText@jbxwqc`}
                        ckConfig={{
                            toolbar: [
                                {name: 'document', items: ['Source']},
                                {
                                    name: 'paragraph',
                                    items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', '-', 'NumberedList', 'BulletedList']
                                },
                                {name: 'styles', items: ['Format', 'Font', 'FontSize']},
                                {name: 'colors', items: ['TextColor']},
                                {name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike',]},
                                {name: 'insert', items: ['Table', 'Smiley']}
                            ],
                            height: 100,
                            autoGrow_minHeight: 100,
                            autoGrow_maxHeight: 100,
                            //uploadUrl: '/api/doc/upload/uploadFile',
                            resize_enabled: false,
                            startupFocus: false,
                        }}
                        onChange={v => this.setfeedbackContent(v)}
                        value={fbcontent}
                        bottomBarRight={{
                            width: 100,
                            Component: [
                                <span className="wea-rich-text-toolbar-bottom-item" style={{position: "relative"}}>
                                  <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@9898f7@submit`} className="wea-button-release" onClick={() => this.submitFb()}>
                                      <span><span className="icon-coms-Release"/><span
                                          style={{marginLeft: '2px'}}>{getLabel('615', '提交')}</span></span>
                                  </Button>
                              </span>
                            ]
                        }}
                        onToolsChange={(name, ids, list, type) => Util.transfStr(name, ids, list, type)}
                    />
                    <FeedBack ecId={`${this && this.props && this.props.ecId || ''}_FeedBack@o47nwg`} dataSource={toJS(fbInfoList)} style={{marginTop: "10px"}}/>
                </WeaSearchGroup>
            </div>
        )
    }
};